package game;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * Class, representing the player in the game with name, sign and current score
 * 
 * @author random.org
 * 
 */

public class Player {

	private static final String[] PLAYER_SIGNS = { "\u2660", "\u2665",
			"\u2666", "\u2663" };

	private String name;
	private String sign;
	private int currentScore;

	public Player(String name) {
		
		setName(name);
		iconChooser();
		
	}

	public void iconChooser() {
		Scanner scan = new Scanner(System.in);
		System.out.println("Available signs: \n" + "1. " + PLAYER_SIGNS[0] + "\n2. "
				+ PLAYER_SIGNS[1] + "\n3. " + PLAYER_SIGNS[2] + "\n4. "
				+ PLAYER_SIGNS[3]);
		System.out.print("Select your icon:");
		try {
			int choice = scan.nextInt();
			setSign(choice);
		} catch (InputMismatchException e) {
			scan.nextLine();
			System.out.println("Please, enter a digit!");
			iconChooser();
		}
		scan.close();
	}

	private void setSign(int choice) {
		if (choice > 0 && choice <= 4) {
			switch (choice) {
			case 1: {
				sign = PLAYER_SIGNS[0];
				break;
			}
			case 2: {
				sign = PLAYER_SIGNS[1];
				break;
			}
			case 3: {
				sign = PLAYER_SIGNS[2];
				break;
			}
			case 4: {
				sign = PLAYER_SIGNS[3];
			}
			}
		}else{
			System.out.println("Please, enter a valid digit!");
			iconChooser();
		}

	}

	/**
	 * increments the current score of the player
	 */
	public void increaseScore() {
		currentScore++;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		if (name != null && !name.equals("")) {
			this.name = name;
		}
	}

	public String getSign() {
		return sign;
	}

	public int getCurrentScore() {
		return currentScore;
	}

}
